<?php
session_start();

require_once("../database.include.php");

	$username=$_GET["username"];
				
    $sql = "SELECT `message`, `user_name`, `expiration_date` FROM `message` 
    WHERE `group_name` IN (SELECT `group_name` FROM `group_user` WHERE `user_name` = '" . $username . "')
    ORDER BY `message_id`";
    
    echo "<table border='1'><tr><td>&nbsp;</td><td>Message</td><td>Author</td></tr>";
    foreach ($conn->query($sql) as $row) {
    	echo "<tr>";
    	echo "<td><input type='checkbox'></td>";
        echo "<td>" . $row['message'] . "</td>";
        echo "<td>" . $row['user_name'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<button onclick='deleteMessages();'>Delete Selected Messages</button>";
?>
